
Imports System.Data.SqlClient
Imports System.Console
Imports System.IO.TextReader
Imports System.IO
Imports System.Net
Imports System.IO.Ports
Imports System.Text
Imports System.Xml
Imports System.IO.FileStream

Imports System.Threading
Imports System.Collections


Public Class GeoWayPoints
    Inherits CollectionBase


    Public Sub Add(ByVal objLinea As GeoPoint)

        Me.List.Add(objLinea)

    End Sub

    Public Sub Remove(ByVal index As Integer)
        If index <= Count - 1 OrElse index >= 0 Then
            Me.List.RemoveAt(index)
        End If
    End Sub

    Public Property Item(ByVal index As Integer) As GeoPoint
        Get
            Return CType(Me.List.Item(index), GeoPoint)
        End Get
        Set(ByVal Value As GeoPoint)
            Me.List.Item(index) = Value
        End Set
    End Property



    Public Function FillPointsInWayPoint(ByVal FechaConsulta As String, _
                                                ByVal HoraMin As String, _
                                                ByVal HoraMax As String _
                                                ) As DataSet

        Try


            Dim StringConecta As String = "User Id=sa2;password=1234;Data Source=127.0.0.1\SQLEXPRESS;Initial Catalog=TEST"
            Dim Conecta1 As New SqlConnection(StringConecta)
            Conecta1.Open()

            Dim Adapter1 As New SqlDataAdapter
            Dim Ds1 As New DataSet

            Dim StringComando1 As String

            StringComando1 = "SELECT * FROM GPSV2 "
            StringComando1 += "WHERE FECHA ='" & FechaConsulta & "' AND "
            StringComando1 += "HORA >= '" & HoraMin & "' AND HORA <= '" & HoraMax & "' "
            StringComando1 += "ORDER BY HORA"

            'MsgBox(StringComando1)

            Dim Comando1 = New SqlCommand(StringComando1, Conecta1)

            Adapter1.SelectCommand = Comando1
            Adapter1.Fill(Ds1, "PuntosW")

            Return Ds1

            Dim Punto As New GeoPoint
            Dim WayPoints As New GeoWayPoints


            Dim Consulta As DataTable = Ds.Tables("Puntos")
            Dim Fila As DataRow

            For Each Fila In Consulta.Rows

                Punto.IDMovil = Fila(0)
                Punto.Fecha = Fila(1)
                Punto.HoraUTC = Fila(2)
                Punto.Latitud = Fila(3)
                Punto.Longitud = Fila(4)
                Punto.Velocidad = Fila(5)

                WayPoints.Add(Punto)

            Next


        Catch ex As Exception

            Dim Punto As New GeoPoint
            Dim WayPoints As New GeoWayPoints

            WayPoints.Add(Punto)


            Return New DataSet


        End Try

    End Function

End Class
